﻿using System.ComponentModel;
using System.Diagnostics.Contracts;

namespace TrackIT.Common.ViewModel
{
    public abstract class ViewModelBase : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void OnPropertyChanged(string propertyName)
        {
            Contract.Requires(propertyName != null);    // propertyName may be empty, for signalling changes to all (or many) properties.

            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
                handler(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}